package capplauncher.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import capplauncher.log.Logger;

public class PhpReader {
	   private URL url;
	   private URLConnection conn;
	   private String result = null;
	   private Logger log;
	   public PhpReader(String link,Logger logger)throws MalformedURLException{
	      url = new URL(link);
	      log = logger;
	   }	
		
	   public String getResult() throws IOException{
		  conn = url.openConnection();
		  if (conn==null){
			  log.log(2, "Auth Server Connection failed!");			  
		  }else{
	         BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	         result = in.readLine();
	         log.log(1, "Auth Server Connected!");
	         log.log(1, "Auth Result: "+result);
	      }
	      return result;
	   }	
			
	}